Streaming Addon Font
Introduction
It is useful to have a custom font streamed if you want to use your custom font for non-html actions
Converting our font
- Find the font you want to in .ttf format I use Google Fonts
- Find a tool for conversion I recommend gfx-font-converter
-
- Put your .ttf font into tools/ folder
-
- In /tools/input.xml change FontName for whatever the Font Name is (e.g. Roboto) and also the input file
-
- Run the conver.ps1 PowerShell script
-
- Rename the .gfx font in output tool for the name we used. (Roboto in our case)
-
- Put the .gfx (Roboto.gfx) into any stream/ folder of your FiveM scripts
- Register your font in your script (must be client side):
RegisterFontFile('Roboto')
local fontId = RegisterFontId('Roboto')
- You can now use the font in 2 ways:
- SetTextFontId
- Changing the string
SetTextFontId(fontId)
-- Example from sqz_chatenhamancements
function DrawText3DsS(x,y,z, text)
local onScreen,_x,_y=World3dToScreen2d(x,y,z)
SetTextScale(0.30, 0.30)
SetTextFont(fontId)
SetTextProportional(1)
SetTextColour(255, 255, 0, 200)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
local factor = (string.len(text)) / 350
DrawRect(_x,_y+0.0115, 0.015+ factor, 0.03, 0, 0, 0, 90)
end
'<font face="Roboto">BLIP NAME</font>'
AddTextComponentString('<font face="Roboto">Ammunation</font>')
I hope this helps to bring your FiveM server your own